/// `SourceMap` structure contained within which is a mapping of a `SourceId` to
/// a `Source`. Each `Source` in the map has been updated (using network
/// operations if necessary) and is ready to be queried for packages.
-pub struct PackageRegistry<'a, 'b: 'a> {
- sources: SourceMap<'a>,
- config: &'a Config<'b>,
+pub struct PackageRegistry<'cfg> {
+ sources: SourceMap<'cfg>,
+ config: &'cfg Config,
// A list of sources which are considered "overrides" which take precedent
// when querying for packages.
Normal,
}
-impl<'a, 'b> PackageRegistry<'a, 'b> {
- pub fn new(config: &'a Config<'b>) -> PackageRegistry<'a, 'b> {
+impl<'cfg> PackageRegistry<'cfg> {
+ pub fn new(config: &'cfg Config) -> PackageRegistry<'cfg> {
PackageRegistry {
sources: SourceMap::new(),
source_ids: HashMap::new(),
Ok(ret)
}
- pub fn move_sources(self) -> SourceMap<'a> {
+ pub fn move_sources(self) -> SourceMap<'cfg> {
self.sources
}
}
}
-impl<'a, 'b> Registry for PackageRegistry<'a, 'b> {
+impl<'cfg> Registry for PackageRegistry<'cfg> {
fn query(&mut self, dep: &Dependency) -> CargoResult<Vec<Summary>> {
let overrides = try!(self.query_overrides(dep));
where F: FnMut(&[String], &Config) -> CliResult<Option<V>>,
V: Encodable
{
- let mut shell = shell(true);
- process_executed((|| {
- let config = try!(Config::new(&mut shell));
+ let mut config = None;
+ let result = (|| {
+ config = Some(try!(Config::new(shell(true))));
let args: Vec<_> = try!(env::args_os().map(|s| {
s.into_string().map_err(|s| {
human(format!("invalid unicode in argument: {:?}", s))
})
}).collect());
- callback(&args, &config)
- })(), &mut shell)
+ callback(&args, config.as_ref().unwrap())
+ })();
+ let mut verbose_shell = shell(true);
+ let mut shell = config.as_ref().map(|s| s.shell());
+ let shell = shell.as_mut().map(|s| &mut **s).unwrap_or(&mut verbose_shell);
+ process_executed(result, shell)
}
pub fn process_executed<T>(result: CliResult<Option<T>>, shell: &mut MultiShell)
let encoded = json::encode(&encodable).unwrap();
println!("{}", encoded);
}
- _ => {}
+ Ok(None) => {}
}
}
use util::{CargoResult, human, ChainError, Config};
use ops::{self, Layout, Context, BuildConfig, Kind};
-pub struct CleanOptions<'a, 'b: 'a> {
+pub struct CleanOptions<'a> {
pub spec: Option<&'a str>,
pub target: Option<&'a str>,
- pub config: &'a Config<'b>,
+ pub config: &'a Config,
}
/// Cleans the project from build artifacts.
use util::{CargoResult, internal, human, ChainError, profile};
/// Contains informations about how a package should be compiled.
-pub struct CompileOptions<'a, 'b: 'a> {
- pub config: &'a Config<'b>,
+pub struct CompileOptions<'a> {
+ pub config: &'a Config,
/// Number of concurrent jobs to use.
pub jobs: Option<u32>,
/// The target platform to compile for (example: `i686-unknown-linux-gnu`).
use sources::PathSource;
use util::{CargoResult, human};
-pub struct DocOptions<'a, 'b: 'a> {
+pub struct DocOptions<'a> {
pub open_result: bool,
- pub compile_opts: ops::CompileOptions<'a, 'b>,
+ pub compile_opts: ops::CompileOptions<'a>,
}
pub fn doc(manifest_path: &Path,
use util::config::{Config};
use util::{CargoResult, human};
-pub struct UpdateOptions<'a, 'b: 'a> {
- pub config: &'a Config<'b>,
+pub struct UpdateOptions<'a> {
+ pub config: &'a Config,
pub to_update: Option<&'a str>,
pub precise: Option<&'a str>,
pub aggressive: bool,
PluginAndTarget,
}
-pub struct Context<'a, 'b: 'a> {
- pub config: &'a Config<'b>,
+pub struct Context<'a> {
+ pub config: &'a Config,
pub resolve: &'a Resolve,
pub sources: &'a SourceMap<'a>,
pub compilation: Compilation,
profiles: &'a Profiles,
}
-impl<'a, 'b: 'a> Context<'a, 'b> {
+impl<'a> Context<'a> {
pub fn new(resolve: &'a Resolve,
sources: &'a SourceMap<'a>,
deps: &'a PackageSet,
- config: &'a Config<'b>,
+ config: &'a Config,
host: Layout,
target_layout: Option<Layout>,
root_pkg: &Package,
build_config: BuildConfig,
- profiles: &'a Profiles) -> CargoResult<Context<'a, 'b>> {
+ profiles: &'a Profiles) -> CargoResult<Context<'a>> {
let target = build_config.requested_target.clone();
let target = target.as_ref().map(|s| &s[..]);
let (target_dylib, target_exe) = try!(Context::filename_parts(target));
/// This function will calculate the fingerprint for a target and prepare the
/// work necessary to either write the fingerprint or copy over all fresh files
/// from the old directories to their new locations.
-pub fn prepare_target<'a, 'b>(cx: &mut Context<'a, 'b>,
- pkg: &'a Package,
- target: &'a Target,
- profile: &'a Profile,
- kind: Kind) -> CargoResult<Preparation> {
+pub fn prepare_target<'a>(cx: &mut Context<'a>,
+ pkg: &'a Package,
+ target: &'a Target,
+ profile: &'a Profile,
+ kind: Kind) -> CargoResult<Preparation> {
let _p = profile::start(format!("fingerprint: {} / {}",
pkg.package_id(), target.name()));
let new = dir(cx, pkg, kind);
///
/// Information like file modification time is only calculated for path
/// dependencies and is calculated in `calculate_target_fresh`.
-fn calculate<'a, 'b>(cx: &mut Context<'a, 'b>,
- pkg: &'a Package,
- target: &'a Target,
- profile: &'a Profile,
- kind: Kind)
- -> CargoResult<Fingerprint> {
+fn calculate<'a>(cx: &mut Context<'a>,
+ pkg: &'a Package,
+ target: &'a Target,
+ profile: &'a Profile,
+ kind: Kind)
+ -> CargoResult<Fingerprint> {
let key = (pkg.package_id(), target, profile, kind);
match cx.fingerprints.get(&key) {
Some(s) => return Ok(s.clone()),
// Returns a mapping of the root package plus its immediate dependencies to
// where the compiled libraries are all located.
-pub fn compile_targets<'a, 'b>(targets: &[(&'a Target, &'a Profile)],
- pkg: &'a Package,
- deps: &PackageSet,
- resolve: &'a Resolve,
- sources: &'a SourceMap<'a>,
- config: &'a Config<'b>,
- build_config: BuildConfig,
- profiles: &'a Profiles)
- -> CargoResult<Compilation> {
+pub fn compile_targets<'a>(targets: &[(&'a Target, &'a Profile)],
+ pkg: &'a Package,
+ deps: &PackageSet,
+ resolve: &'a Resolve,
+ sources: &'a SourceMap<'a>,
+ config: &'a Config,
+ build_config: BuildConfig,
+ profiles: &'a Profiles)
+ -> CargoResult<Compilation> {
if targets.is_empty() {
return Ok(Compilation::new(pkg))
}
Ok(cx.compilation)
}
-fn compile<'a, 'b>(targets: &[(&'a Target, &'a Profile)],
- pkg: &'a Package,
- cx: &mut Context<'a, 'b>,
- jobs: &mut JobQueue<'a>) -> CargoResult<()> {
+fn compile<'a>(targets: &[(&'a Target, &'a Profile)],
+ pkg: &'a Package,
+ cx: &mut Context<'a>,
+ jobs: &mut JobQueue<'a>) -> CargoResult<()> {
debug!("compile_pkg; pkg={}", pkg);
let profiling_marker = profile::start(format!("preparing: {}", pkg));
Ok(())
}
-fn prepare_init<'a, 'b>(cx: &mut Context<'a, 'b>,
- pkg: &'a Package,
- jobs: &mut JobQueue<'a>,
- visited: &mut HashSet<&'a PackageId>) {
+fn prepare_init<'a>(cx: &mut Context<'a>,
+ pkg: &'a Package,
+ jobs: &mut JobQueue<'a>,
+ visited: &mut HashSet<&'a PackageId>) {
if !visited.insert(pkg.package_id()) { return }
// Set up all dependencies
use ops::{self, ExecEngine, ProcessEngine, Compilation};
use util::{self, CargoResult, ProcessError};
-pub struct TestOptions<'a, 'b: 'a> {
- pub compile_opts: ops::CompileOptions<'a, 'b>,
+pub struct TestOptions<'a> {
+ pub compile_opts: ops::CompileOptions<'a>,
pub no_run: bool,
}
/* TODO: Refactor GitSource to delegate to a PathSource
*/
-pub struct GitSource<'a, 'b:'a> {
+pub struct GitSource<'cfg> {
remote: GitRemote,
reference: GitReference,
db_path: PathBuf,
checkout_path: PathBuf,
source_id: SourceId,
- path_source: Option<PathSource<'a, 'b>>,
+ path_source: Option<PathSource<'cfg>>,
rev: Option<GitRevision>,
- config: &'a Config<'b>,
+ config: &'cfg Config,
}
-impl<'a, 'b> GitSource<'a, 'b> {
+impl<'cfg> GitSource<'cfg> {
pub fn new(source_id: &SourceId,
- config: &'a Config<'b>) -> GitSource<'a, 'b> {
+ config: &'cfg Config) -> GitSource<'cfg> {
assert!(source_id.is_git(), "id is not git, id={}", source_id);
let reference = match source_id.git_reference() {
return url;
}
-impl<'a, 'b> Debug for GitSource<'a, 'b> {
+impl<'cfg> Debug for GitSource<'cfg> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
try!(write!(f, "git repo at {}", self.remote.url()));
}
}
-impl<'a, 'b> Registry for GitSource<'a, 'b> {
+impl<'cfg> Registry for GitSource<'cfg> {
fn query(&mut self, dep: &Dependency) -> CargoResult<Vec<Summary>> {
let src = self.path_source.as_mut()
.expect("BUG: update() must be called before query()");
}
}
-impl<'a, 'b> Source for GitSource<'a, 'b> {
+impl<'cfg> Source for GitSource<'cfg> {
fn update(&mut self) -> CargoResult<()> {
let actual_rev = self.remote.rev_for(&self.db_path, &self.reference);
let should_update = actual_rev.is_err() ||
use util::{self, CargoResult, internal, internal_error, human, ChainError};
use util::{MTime, Config};
-pub struct PathSource<'a, 'b: 'a> {
+pub struct PathSource<'cfg> {
id: SourceId,
path: PathBuf,
updated: bool,
packages: Vec<Package>,
- config: &'a Config<'b>,
+ config: &'cfg Config,
}
// TODO: Figure out if packages should be discovered in new or self should be
// mut and packages are discovered in update
-impl<'a, 'b> PathSource<'a, 'b> {
- pub fn for_path(path: &Path, config: &'a Config<'b>)
- -> CargoResult<PathSource<'a, 'b>> {
+impl<'cfg> PathSource<'cfg> {
+ pub fn for_path(path: &Path, config: &'cfg Config)
+ -> CargoResult<PathSource<'cfg>> {
trace!("PathSource::for_path; path={}", path.display());
Ok(PathSource::new(path, &try!(SourceId::for_path(path)), config))
}
/// Invoked with an absolute path to a directory that contains a Cargo.toml.
/// The source will read the manifest and find any other packages contained
/// in the directory structure reachable by the root manifest.
- pub fn new(path: &Path, id: &SourceId, config: &'a Config<'b>)
- -> PathSource<'a, 'b> {
+ pub fn new(path: &Path, id: &SourceId, config: &'cfg Config)
+ -> PathSource<'cfg> {
trace!("new; id={}", id);
PathSource {
}
}
-impl<'a, 'b> Debug for PathSource<'a, 'b> {
+impl<'cfg> Debug for PathSource<'cfg> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "the paths source")
}
}
-impl<'a, 'b> Registry for PathSource<'a, 'b> {
+impl<'cfg> Registry for PathSource<'cfg> {
fn query(&mut self, dep: &Dependency) -> CargoResult<Vec<Summary>> {
let mut summaries: Vec<Summary> = self.packages.iter()
.map(|p| p.summary().clone())
}
}
-impl<'a, 'b> Source for PathSource<'a, 'b> {
+impl<'cfg> Source for PathSource<'cfg> {
fn update(&mut self) -> CargoResult<()> {
if !self.updated {
let packages = try!(self.read_packages());
static DEFAULT: &'static str = "https://github.com/rust-lang/crates.io-index";
-pub struct RegistrySource<'a, 'b:'a> {
+pub struct RegistrySource<'cfg> {
source_id: SourceId,
checkout_path: PathBuf,
cache_path: PathBuf,
src_path: PathBuf,
- config: &'a Config<'b>,
+ config: &'cfg Config,
handle: Option<http::Handle>,
- sources: Vec<PathSource<'a, 'b>>,
+ sources: Vec<PathSource<'cfg>>,
hashes: HashMap<(String, String), String>, // (name, vers) => cksum
cache: HashMap<String, Vec<(Summary, bool)>>,
updated: bool,
kind: Option<String>,
}
-impl<'a, 'b> RegistrySource<'a, 'b> {
+impl<'cfg> RegistrySource<'cfg> {
pub fn new(source_id: &SourceId,
- config: &'a Config<'b>) -> RegistrySource<'a, 'b> {
+ config: &'cfg Config) -> RegistrySource<'cfg> {
let hash = hex::short_hash(source_id);
let ident = source_id.url().host().unwrap().to_string();
let part = format!("{}-{}", ident, hash);
}
}
-impl<'a, 'b> Registry for RegistrySource<'a, 'b> {
+impl<'cfg> Registry for RegistrySource<'cfg> {
fn query(&mut self, dep: &Dependency) -> CargoResult<Vec<Summary>> {
// If this is a precise dependency, then it came from a lockfile and in
// theory the registry is known to contain this version. If, however, we
}
}
-impl<'a, 'b> Source for RegistrySource<'a, 'b> {
+impl<'cfg> Source for RegistrySource<'cfg> {
fn update(&mut self) -> CargoResult<()> {
// If we have an imprecise version then we don't know what we're going
// to look for, so we always atempt to perform an update here.
use self::ConfigValue as CV;
-pub struct Config<'a> {
+pub struct Config {
home_path: PathBuf,
- shell: RefCell<&'a mut MultiShell>,
+ shell: RefCell<MultiShell>,
rustc_version: String,
/// The current host and default target of rustc
rustc_host: String,
cwd: PathBuf,
}
-impl<'a> Config<'a> {
- pub fn new(shell: &'a mut MultiShell) -> CargoResult<Config<'a>> {
+impl Config {
+ pub fn new(shell: MultiShell) -> CargoResult<Config> {
let cwd = try!(env::current_dir().chain_error(|| {
human("couldn't get the current directory of the process")
}));
self.home_path.join("registry").join("src")
}
- pub fn shell(&self) -> RefMut<&'a mut MultiShell> {
+ pub fn shell(&self) -> RefMut<MultiShell> {
self.shell.borrow_mut()
}
}
}
-struct Context<'a, 'b, 'c: 'b> {
+struct Context<'a, 'b> {
deps: &'a mut Vec<Dependency>,
source_id: &'a SourceId,
nested_paths: &'a mut Vec<PathBuf>,
- config: &'b Config<'c>,
+ config: &'b Config,
}
// These functions produce the equivalent of specific manifest entries. One